<?php

abstract class EAdmin_Page_Abstract extends ME_Abstract_Page
{
	/**
	* @var ME_DAL_RefreshCacheLoader
	*/
	protected static $_cache;
	
	protected static $_dbGameData;
	
	protected function _loadDb()
	{
	}
    
	public function __construct(ME_Request $input, ME_Response $output)
	{
		$this->_loadDb();

		$output->execName =
		$input->execName  = $input->getExecName();
		
		$output->actName  =
		$input->actName   = $input->getActionName();
		
		$output->ctlName  =
		$input->ctlName   = $input->getControllerName();
		
		$input->baseUrl = 
		$output->baseUrl = '/Html/EAdmin';
	}
	
	/**
	* 初始化缓存
	*/
	public static function init()
	{
		self::$_cache = ME_DAL_RefreshCacheLoader::getInstance();
	}
	
	/**
	* 加载缓存
	* @return array DAL data
	*/
	protected static function loadCache($moduleName, $param = array(), $num = 0)
	{
		self::init();
		$data = self::$_cache->loadCacheObject($moduleName, $param);

		if ($num && $data && count($data) > $num) {
			$data = array_slice($data, 0, $num, true);
		}

		return $data;
	}
	
	/**
	* 更新缓存
	* 
	* @param string $moduleName
	* @param array  $param
	* @return boolean
	*/
	protected static function refreshCache($moduleName, $param = array())
	{
		self::init();
		return self::$_cache->refreshCacheObject($moduleName, $param);
	}
	
	/**
	 * 公用提示函数
	 *
	 * @param $msg 消息内容
	 * @param $url 跳转的地址
	 * @param $back 是否返回上一页
	 */
	protected static function showMsg($msg,$url='',$back=0)
	{
		if(!$msg) $msg = '自定义提示消息';
		if($back){
			echo '<script type="text/javascript">history.go(-1);</script>';
		} else {
			if(!$url) return '';
			echo '<script type="text/javascript">alert("'.$msg.'");location.href="/Html/EAdmin'.$url.'";</script>';
			//die();
		}
	}
}
